<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of customer
 *
 * @author user
 */
class Customer extends Controller{
    //put your code here
    function index(){
        
        //$this->load->library('db_customer');
        $this->load->model('pegawai/Customer_model','cust', TRUE);
        if ($this->input->post('nama')!="")
        {
            if ($this->input->post('id')=="")
            {
                $this->cust->insert($this->input->post('nama'), $this->input->post('no_hp'));
            } else
            {
                $this->cust->update($this->input->post('id'),$this->input->post('no_hp'),$this->input->post('nama'));
            }
        }
        $this->load->helper('url');
        $data['customers'] = $this->cust->retr_customer_list();
        $this->load->view('menu');
        $this->load->view('pegawai/customer_view',$data);
//        foreach ($data as $print){
//            echo $print->nama. "<br/>";
//        }


    }

    function edit($id)
    {
        //$this->load->library('db_customer');
        $this->load->model('pegawai/Customer_model','cust', TRUE);
        $result =  $this->cust->retr_id($id);
        $data = array(
            "result" => $result
        );
        $this->load->view('menu');
        $this->load->view('pegawai/customer_form',$data);
    }
    function delete($id)
    {
        delete_where_id($id);
        index();
    }
    function add()
    {
        $this->load->view('menu');
        $this->load->view('pegawai/customer_form');
    }
}
?>
